<template>
  <div id="app">
    <!-- <nav>
      <router-link to="/home" tag="button">首页</router-link>
      <router-link to="/about" tag="button">关于</router-link>
      <router-link v-bind:to="'/profile/' + userId" tag="button">我的</router-link>
      <router-link v-bind:to="{path:'/profile/' + userId,query:{name:'浩哥', sex:'nv',age:18,height:155}}" tag="button">我的</router-link>
    </nav> -->

    <nav>
      <button @click="homeClick">首页</button>
      <button @click="aboutClick">关于</button>
      <button @click="profileClick">我的</button>
    </nav>
    
    <!-- 正则表达式 组件的name值 -->
    <keep-alive include="home">
      <router-view/>
    </keep-alive>
  </div>
</template>

<script>
export default {
  name: 'App',
  data(){
    return {
      userId:'kfc'
    }
  },
  methods:{
    homeClick(){
      this.$router.replace("/home").catch(err => err);
    },
    aboutClick(){
      this.$router.replace("/about").catch(err => err);
    },
    profileClick(){
      this.$router.replace({
        path:'/profile/' + this.userId,
        query:{
          name:"浩哥",
          sex:"恨",
          age:99,
          height:155
        }
      }).catch(err => err);
    }
  }
}
</script>

<style>

</style>
